package com.android.qjpmc.widget.manager;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.android.qjpmc.widget.db.DaoMaster;

import com.github.yuweiguocn.library.greendao.MigrationHelper;

import org.greenrobot.greendao.database.Database;

/**
 * @Author zhangshuqi
 * @CreateTime 2018/3/16
 * @Describe
 */

public class DBDaoManager extends DaoMaster.OpenHelper {
    // private String title;
    // private Context context;

    public DBDaoManager(Context context, String name) {
        super(context, name);
        //  this.context = context;
        //  this.title = title;

    }


    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        MigrationHelper.migrate(db, new MigrationHelper.ReCreateAllTableListener() {

                    @Override
                    public void onCreateAllTables(Database db, boolean ifNotExists) {
                        DaoMaster.createAllTables(db, ifNotExists);
                    }

                    @Override
                    public void onDropAllTables(Database db, boolean ifExists) {
                        DaoMaster.dropAllTables(db, ifExists);
                    }
                }
        );
      /*  DownloadChapterBeanDao.createTable(db, ifNotExists);
        DownloadCourseBeanDao.createTable(db, ifNotExists);
        DownloadCourseClassBeanDao.createTable(db, ifNotExists);
        DownloadSectionBeanDao.createTable(db, ifNotExists);
        DownloadVideoBeanDao.createTable(db, ifNotExists);
        SearchHistoryBeanDao.createTable(db, ifNotExists);
        StudyTimeBeanDao.createTable(db, ifNotExists);*/

    }

}
